package xjtu.se.articlecommunity.buser.queuemanage.dao;


import org.apache.ibatis.annotations.*;
import xjtu.se.articlecommunity.buser.queuemanage.dto.InsFeedDto1;
import xjtu.se.articlecommunity.buser.queuemanage.dto.OrderDto;

public interface QueueManageDao {
    @Select("select * from t_feed where a_order=#{a_order}-1 and at_tab=#{at_tab}")
    OrderDto getAbove(OrderDto dto);
    @Select("select * from t_feed where a_order=#{a_order}+1 and at_tab=#{at_tab}")
    OrderDto getBelow(OrderDto dto);

    @Update("update t_feed set a_id=#{a_id} where a_order=#{a_order}-1 and at_tab=#{at_tab}")
    void updateAbove(OrderDto dto);
    @Update("update t_feed set a_id=#{a_id} where a_order=#{a_order}+1 and at_tab=#{at_tab}")
    void updateBelow(OrderDto dto);

    @Delete("delete from t_feed where a_order=#{a_order} and a_id=#{a_id} and at_tab=#{at_tab}")
    void delFeed(OrderDto dto);

    @Select("select count(*) from art_tab where a_id=#{a_id} and at_tab=#{at_tab}")
    int checkArt(@Param("a_id") String a_id, @Param("at_tab") String at_tab);
    @Select("select count(*) from t_feed where a_id=#{a_id} and at_tab=#{at_tab}")
    int checkFeed(@Param("a_id") String a_id, @Param("at_tab") String at_tab);

    @Update("update t_feed set a_order=a_order+1 where a_order>=#{a_order} and at_tab=#{at_tab}")
    void MoveFeedDown(@Param("a_order") int a_order, @Param("at_tab") String at_tab);
    @Update("update t_feed set a_order=a_order-1 where a_order>#{a_order} and at_tab=#{at_tab}")
    void MoveFeedUp(@Param("a_order") int a_order, @Param("at_tab") String at_tab);

    @Insert("insert into t_feed values(#{a_order},#{a_id},#{at_tab})")
    void InsertFeed(@Param("a_order") int a_order, @Param("a_id") String a_id, @Param("at_tab") String at_tab);

}
